{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import networkx as nx\n",
    "from sklearn.metrics import pairwise\n",
    "\n",
    "# 创建网络模型\n",
    "G = nx.karate_club_graph()\n",
    "\n",
    "# 计算PageRank\n",
    "pagerank = nx.pagerank(G)\n",
    "\n",
    "# 计算聚类系数\n",
    "clustering = nx.clustering_coefficient(G)\n",
    "\n",
    "# 结合PageRank和聚类系数评估影响力\n",
    "influence = {}\n",
    "for node in G.nodes():\n",
    "    influence[node] = pagerank[node] * clustering[node]\n",
    "\n",
    "# 输出影响力排名\n",
    "sorted_influence = sorted(influence.items(), key=lambda x: x[1], reverse=True)\n",
    "for rank, (node, score) in enumerate(sorted_influence, start=1):\n",
    "    print(f\"Rank {rank}: Node {node}, Influence Score {score}\")"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
